//
//  FirmwareInformationController.swift
//  DaRings
//
//  Created by 易先生 on 2022/10/31.
//

import UIKit
import MYModule

open class FirmwareInformationController: BaseViewController {

    open override func viewDidLoad() {
        super.viewDidLoad()
        

    }
    
    open override func makeUI() {
        super.makeUI()
        
        self.navigation.bar.backgroundColor = UIColor.darkBackground
        view.backgroundColor =  UIColor.darkBackground
        
        view.addSubview(titleView)
        view.addSubview(tableView)
        
        titleView.snp.makeConstraints { make in
            make.top.equalTo(topLayoutGuide.snp.bottom)
            make.leading.equalToSuperview()
            make.trailing.equalToSuperview()
        }

        tableView.snp.makeConstraints { make in
            make.top.equalTo(titleView.snp.bottom)
            make.leading.trailing.bottom.equalToSuperview()
        }
    }
    
    open override func bindViewModel() {
        super.bindViewModel()
        viewModel.firmwareInformationItems.bind(to: tableView.rx.items(cellIdentifier: FirmwareInformationCell.reuseIdentifier, cellType: FirmwareInformationCell.self)) {row, item, cell in
            cell.bind(to: item)
        }.disposed(by: rx.disposeBag)
    }
    
    private lazy var viewModel: FirmwareInformationViewModel = {
        let viewModel = FirmwareInformationViewModel()
        return viewModel
    }()
    
    private lazy var titleView: TopTitleView = {
        let titleView = TopTitleView()
        titleView.configTitle(title: "firmware_information_title".language)
        return titleView
    }()
    
    private lazy var tableView: TableView = {
        let tableView = TableView(frame: .zero, style: .plain)
        tableView.separatorColor = UIColor.assist_D0D0D0
        tableView.backgroundColor = .clear
        tableView.rowHeight = 54
        tableView.separatorInset = UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 30)
        tableView.register(FirmwareInformationCell.self, forCellReuseIdentifier: FirmwareInformationCell.reuseIdentifier)
        return tableView
    }()
}
